#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n;
ll x;
void solve()
{
	cin >> n;
	map<ll, int> cnt;
	map<ll, ll> last;
	cnt[0] = 1;
	for (int i = 0; i < n; i++)
	{
		string op;
		cin >> op >> x;
		if (op[0] == '+') cnt[x] = 1;
		else
		{
			ll cur = last[x];//减少下次问这个数的倍数时的重复计算量,last的v记录的是某个数上次求得的最小x倍数不在cnt的答案
			//cout<<"test: "<<cur<<'\n';
			while (cnt[cur]) cur += x;
			last[x] = cur;
			cout << cur << '\n';
		}
	}
}

int main()
{
	close();
	//int T; cin >> T;
	//while (T--) solve();
	solve();
	return 0;
}